import 'package:flutter/material.dart';
import 'package:flutter_bmfmap_example/service/marketservice.dart';

import 'ordermodel.dart';

class Orderinfomodel with ChangeNotifier {

  List<OrderItem> orderlist =
      OrdersList([]).list;

  Future<void> init() async {
    var result = await Marketservice.getOrederlist();
    orderlist = OrdersList.fromJson(result).list;   
    print(orderlist.length);                                                                                                                                                                                                                                                                                               
    notifyListeners();
  }

  List getorderlistbytype(int type){
    if(type == -1){
      return orderlist;
    }
    else {
      List orderlist2 = [];
      for(int i = 0;i<orderlist.length;i++){
        if(orderlist[i].state==type)orderlist2.add(orderlist[i]);
      }
      return orderlist2;
    }
  }

  
}